<?php
//get all theme
$themePath = FCPATH.'application/views/shop-themes/';
$aShopThemeInfo = scandir($themePath);
foreach($aShopThemeInfo as $index=>$folder) {
    if(!is_dir($themePath . $folder) || $folder=='.' || $folder=='..'){
        unset($aShopThemeInfo[$index]);
    }
}
?>
<div class="tab-pane fade" id="shopdetailpane">
    <form class="form-horizontal" role="form" method="post" action="<?php echo page_url('gian-hang/cap-nhat-chi-tiet'); ?>">
        <div class="form-group">
            <label for="shop-template" class="col-md-2 control-label">Giao diện</label>
            <div class="col-md-3">
                <select name="setting_template" class="form-control" id="shop-template">
                    <?php foreach($aShopThemeInfo as $index=>$folder) { ?>
                    <?php $selected = $shop->template==$folder?"selected='selected'":""; ?>
                    <option value="<?php echo $folder; ?>" data-index='<?php echo $index; ?>' <?php echo $selected?>>
                        <?php echo $folder; ?>
                    </option>
                    <?php } ?>
                </select>
            </div>
            <div class="col-md-3">
                <button type="button" class="btn btn-success" data-toggle="modal" data-target="#modal-preview-theme"><i class="glyphicon glyphicon-picture"></i> Xem thử</button>
            </div>
        </div>

        <div class="form-group">
            <label for="shop-template" class="col-md-2 control-label">Trang trên menu</label>
            <div class="col-md-10">
                <?php foreach ($shop_page_available as $key => $page) { ?>
                <label class="checkbox-inline">
                    <?php
                    $checked = "";
                    foreach ($shop_page as $key2 => $value) {
                        if($page->getId() == $value->getId()){
                            $checked = "checked='checked'";
                        }
                    }
                    ?>
                    <input type="checkbox" name="setting_page[]" value="<?php echo $page->getId(); ?>" <?php echo $checked ;?> /> <?php echo $page->getTitle();?>
                </label>
                <?php } ?>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-4 col-md-offset-2">
                <button id="btn-upload" type="button" class="btn btn-default" data-toggle="modal" data-backdrop="static" data-target="#modal-change-banner">
                    <i class="glyphicon glyphicon-picture"></i>&nbsp;
                    Banner&nbsp;
                </button>
                <button id="btn-upload" type="button" class="btn btn-default" data-toggle="modal" data-backdrop="static" data-target="#modal-change-slide">
                    <i class="glyphicon glyphicon-play"></i>&nbsp;
                    Slide&nbsp;
                </button>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-4 col-md-offset-2">
                <input id="shop_id" name="shop_id" type="hidden" value="<?php echo $this->encrypt->encode($shop->getId()); ?>" />
                <input id="shop_banner" name="setting_banner" type="hidden" value="<?php echo SHOP_BANNER_IMAGE_URL.$shop->banner; ?>" />
                <p id="ar-slide" class="hidden">
                    <?php foreach ($shop_slide as $key => $value) { ?>
                    <input name='setting_slide[]' type="hidden" value="<?php echo SHOP_SLIDE_IMAGE_URL.$value->image; ?>" />
                    <?php } ?>
                </p>
                <button type="button" id="user-shop-update-btn" class="btn btn-success">
                    <i class="glyphicon glyphicon-ok-sign"></i>&nbsp;
                    Lưu&nbsp;
                </button>
            </div>
        </div>
    </form>
</div>

<?php $this->load->view('backend/user/modal-shop-image.html.php', array('shop'=>$shop, 'shop_page'=>$shop_page, 'shop_slide'=>$shop_slide)); ?>